package zhoufu.sz.sanxiao_check.models;

import android.databinding.ObservableField;

/**
 * 项目： ${PACKGE_NAME}
 * 时间： 2016/6/18 17:06
 * 人员： hyc
 * 功能：
 */

public class User extends LoginModel<User> {

    public static String SAVE_USER="save_user";
    private static User                    mUser;
    private        ObservableField<String> name;
    private        ObservableField<String> password;

    private boolean isPhone;

    public User()
    {
        name=new ObservableField<>();
        password=new ObservableField<>();

    }

    public boolean isPhone()
    {
        return isPhone;
    }

    public void setPhone(boolean isPhone)
    {
        this.isPhone = isPhone;
    }

    /**
     * User 已经在 {@link #putInstance(User)}中初始化.
     */
    public static User readUser()
    {

        if ( mUser == null )
        {
            mUser = new User();
        }
        return mUser;
    }

    public void storeUser()
    {
        new Thread()
        {
            @Override
            public void run()
            {
//                SharedPreferencesUtil.saveEntity(UIUtils.getContext(),
//                        mUser, "key_user");
            }
        }.start();
    }

    public String getName()
    {
        return name.get();
    }

    public void setName(String name)
    {
        this.name.set(name);
    }

    public String getPassword()
    {
        return password.get();
    }

    public void setPassword(String password)
    {
        this.password.set(password);
    }


    public static void putInstance(User user) {
        mUser=user;
    }
}
